/*
 * Copyright (c) 2025, 廖树财, <study_2030@163.com>
 *
 * PES1.0.3-YCYW is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2     
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
#pragma once
#include "define.h"
#include "cjson/cJSON.h"
#include <stdlib.h>
#include <pthread.h>
#include "ctrl.h"
#include "zlog.h"
#include "http.h"
#include "common.h"
#include "upload.h"
#define HASH_HEX_SIZE (SHA256_DIGEST_LENGTH * 2 + 1)

typedef struct st_IOTA_UPDATE_PROBE_PARAM
{
    char *fileId;
    char *fileName;
    char *digestAlgorithm;
    char *digest;
    char *fileType;
    char* fileVersion;
} IOTA_UPDATE_PROBE_PARAM;

typedef struct st_IOTA_UPDATE_FIRMWARE_PARAM
{
    char* firmwareName;
    char* firmwareId;
    char* fileId;
} IOTA_UPDATE_FIRMWARE_PARAM;

typedef struct st_IOTA_UPDATE_CONF_PARAM
{
    char* path;
    char* configName;
} IOTA_UPDATE_CONF_PARAM;

bool JsonToStruct_ServiceUpdate(char *pcJson, ST_IOTA_LOG *pcStatusDecs);

bool JsonToStruct_ServiceUpdate_V1(char* pcJson, ST_IOTA_LOG* pcStatusDecs);

int ServiceUpdate(char *pJson, bool isUpdate);

int terminalServiceUpdate(char *pJson);
